package com.laikan.bos.dao.base;

import com.laikan.bos.domain.base.Standard;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by admin on 2017/11/10.
 */
@Repository
/*@NamedQueries(@NamedQuery(name = "Standard.queryName2",query = "from Standard where name = ?"))*/
public interface StandardRepository extends JpaRepository<Standard,Integer>{

    public List<Standard> findByName(String name);

    // nativeQuery 为 false 配置JPQL 、 为true 配置SQL
    @Query(value = "from Standard where name = ?",nativeQuery = false)
    public List<Standard> queryName(String name);

   /* @Query
    public List<Standard> queryName2(String name);*/


    @Query(value = "update Standard set minLength=?2 where id = ?1")
    @Modifying
    public void updateMinLength(Integer id, Integer minLength);

    @Query(value = "from Standard where id = ?",nativeQuery = false)
    public Standard queryName3(Integer id);

    @Query(value = "select * from t_standard where c_id = ?",nativeQuery = true)
    public Standard queryName4(Integer id);
}
